<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>合伙人数据分析</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <link rel="stylesheet" href="${ctx}/css/ui/activity/member_act_list.css">

</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/activity/memberAct/memberCourseList.do?actId=${activity.id}&relationId=${relationId}"
                  id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">手机号：</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="mobile" autocomplete="off" class="layui-input"
                                           value="${memberAct.mobile}"
                                           placeholder="请输入查询手机号"
                                    >
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">微信号：</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="wechatNum" autocomplete="off" class="layui-input"
                                           value="${memberAct.wechatNum}"
                                           placeholder="请输入查询微信号"
                                    >
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger"
                                       href="javascript:submitFunction('#myForm')">查询</a>
                                    <a class="layui-btn layui-btn-normal"
                                       href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">更新时间：</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart"
                                               value="${input.createStart}" placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd"
                                               value="${input.createEnd}" placeholder="截止日">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="my-act-list-content">
                <ul class="num">
                    <div class="l">
                        <li class="f16">报名人数<span class="red">${page.totalCount}</span>人</li>
                    </div>
<%--                    <div class="l">
                        <li style="cursor: pointer;" class="r">
                            <a class="layui-btn layui-btn-danger layui-btn-sm" id="btnExport">导出EXCEL</a>
                        </li>
                    </div>--%>
                    <p class="cl"></p>
                </ul>
                <div class="cl">
                    <table class="layui-table" lay-skin="line" id="myTable">
                        <colgroup>
                            <col>
                            <col>
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                            <col width="8%">
                            <col width="8%">
                            <col>
                            <col width="10%">
                            <col width="80px">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>参与者</th>
                            <th>手机号</th>
                            <th>微信号</th>
                            <th>报名方式</th>
                            <th>金额</th>
                            <th>报名状态</th>
                            <th>签到</th>
                            <th>更新时间</th>
                            <th>直接佣金收入</th>
                            <th style="text-align: center">展开</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="memberAct" items="${memberActs}">
                            <tr class="info" data-id="${memberAct.id}">
                                <td class="table-member"
                                    onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${memberAct.member.id}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo common-img">
                                            <img src="<c:if test="${memberAct.member.logo != null}">${memberAct.member.logo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1"><a class="blue"
                                                                               title="${memberAct.member.realname}"
                                                                               href="javascript:void(0);">${memberAct.member.realname}</a>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <div>${memberAct.mobile}</div>
                                </td>
                                <td>
                                    <div class="member-name ellipsis-1">${memberAct.wechatNum}</div>
                                </td>
                                <td>
                                    <div>
                                        <c:choose>
                                            <c:when test="${memberAct.counterType == 1}">免费</c:when>
                                            <c:when test="${memberAct.counterType == 2}">在线付费</c:when>
                                            <c:when test="${memberAct.counterType == 3}">线下付费</c:when>
                                        </c:choose>
                                    </div>
                                </td>
                                <td>
                                    <div>
                                        <c:if test="${memberAct.counterPrice == 0}">免费报名</c:if>
                                        <c:if test="${memberAct.counterPrice != 0}">¥${memberAct.counterPrice}</c:if>
                                    </div>
                                </td>
                                <td>
                                    <div>
                                        <c:choose>
                                            <c:when test="${memberAct.checkStatus == 0}">
                                                <span>审核中</span>
                                            </c:when>
                                            <c:when test="${memberAct.checkStatus == 1}">
                                                <span>待支付</span>
                                            </c:when>
                                            <c:when test="${memberAct.checkStatus == 2}">
                                                <span>审核拒绝</span>
                                            </c:when>
                                            <c:when test="${memberAct.checkStatus == 3}">
                                                <span>报名成功</span>
                                            </c:when>
                                            <c:when test="${memberAct.checkStatus == 4}">
                                                <span>已取消</span>
                                            </c:when>
                                            <c:when test="${memberAct.checkStatus == 5}">
                                                <span>未参与</span>
                                            </c:when>
                                        </c:choose>
                                    </div>
                                </td>
                                <td>
                                    <div>${memberAct.signin == 1 ? '已签到' : '未签到'}</div>
                                </td>
                                <td>
                                    <div><fmt:formatDate value="${memberAct.updateDate}"
                                                         pattern="yyyy-MM-dd HH:mm"/></div>
                                </td>
                                <td>
                                    <div>${memberAct.directlyBrokerage}</div>
                                </td>
                                <td>
                                    <div class="option">
                                        <i class="iconfont icon-unfold"></i>
                                        <i class="iconfont icon-fold dis-none"></i>
                                    </div>
                                </td>
                            </tr>
                            <tr class="dis-none info-detail">
                                <td colspan="10">
                                    <div>
                                        <table width="100%" class="childTable layui-table" lay-skin="row"
                                               style="margin: 0px">
                                            <tbody>
                                            <c:if test="${not empty memberAct.name}">
                                                <tr>
                                                    <td>联系人</td>
                                                    <td>${memberAct.name}</td>
                                                </tr>
                                            </c:if>
                                            <c:if test="${not empty memberAct.company}">
                                                <tr>
                                                    <td>公司名称</td>
                                                    <td>${memberAct.company}</td>
                                                </tr>
                                            </c:if>
                                            <c:if test="${not empty memberAct.jobTitle}">
                                                <tr>
                                                    <td>公司职位</td>
                                                    <td>${memberAct.jobTitle}</td>
                                                </tr>
                                            </c:if>
                                            <c:if test="${not empty memberAct.extra}">
                                                <tr>
                                                    <td>备注信息</td>
                                                    <td>${memberAct.extra}</td>
                                                </tr>
                                            </c:if>
                                            <c:if test="${not empty memberAct.remarks}">
                                                <tr>
                                                    <td>付款备注</td>
                                                    <td>${memberAct.remarks}</td>
                                                </tr>
                                            </c:if>
                                            </tbody>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
    <div id="bmDialog">
        <form class="layui-form p10" action="${ctx}/activity/memberAct/verify2.do" id="infoForm">
            <input type="hidden" name="id" value=""/>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 30px;padding-left: 0px;">备注<span class="f-verify-red">*</span></label>
                <div class="layui-input-block" style="margin-left: 50px;">
                    <textarea name="remarks" class="layui-textarea"></textarea>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/html" id="form_template">
    {{# for(var i = 0; i < d.fields.length; i++){ }}
        <tr class="other-info">
            {{# var thatValue = ''; }}
            {{# for(var j = 0; j < d.infos.length; j++){ }}
                {{# if(d.fields[i].id == d.infos[j].fieldId){ }}
                    {{# thatValue = d.infos[j].fieldValue }}
                {{# } }}
            {{# } }}
            <td><div style="word-break: break-all;">{{ d.fields[i].title }}</div></td>
            <td><div style="word-break: break-all;">{{ thatValue }}</div></td>
        </tr>
    {{# } }}
</script>
<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    var laytpl = null, formItems;
    $(function () {
        layui.use(['laytpl'], function () {
            laytpl = layui.laytpl;
        });
    });

    showActive('${input.createStart}', '${input.createEnd}', '#timeType');
    txz.initHeader({
        nav:[{
            name: '合伙人数据分析',
            href: '${ctx}/copartner/analyze/list.do'
        },{
            name: '${realname}'
        },{
            name: '${activity.title}'
        },{
            name: '数据详情',
            curr: true
        }],
        info:'<span class="f12">共<b>${page.totalCount}</b>条记录',
        btns: [{
            name: '返回',
            icon: 'back',
            href: '${ctx}/copartner/analyze/courseDistributeList.do?parentId=${parentId}'
        }]
    });
    function check(content, memberActId, checkStatus) {
        layer.confirm(content, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/activity/memberAct/verify.do", {
                id: memberActId,
                checkStatus: checkStatus
            }, function (data) {
                layer.close(loadIndex);
                setTimeout(function () {
                    if (data.success == true) {
                        util.layerAlertSuccess("审核成功", function () {
                            window.location.reload();
                        })
                    } else {
                        util.layerAlertError("审核失败")
                    }
                }, 500);
            })
        });
    }

    function lookLink(memberActId) {
        $("#infoForm").find("[name=id]").val(memberActId);
    }

    function setPayStatus(targetName, targetId) {
        var setPayIndex = layer.open({
            type: 1,
            area: '400px',
            title: '标记为已付款——' + targetName,
            content: $("#bmDialog"),
            btn: ['确定', '取消'],
            success: function () { // 弹出后回调
                $("#infoForm").find("[name=remarks]").val("");
                $("#infoForm").find("[name=id]").val(targetId);
            },
            end: function () { // 销毁后回调
                $("#infoForm").find("[name=remarks]").val("");
                $("#infoForm").find("[name=id]").val("");
            },
            yes: function () { // 确定按钮
                var remarks = $("#infoForm [name=remarks]").val();
                if (remarks == "") {
                    util.layerMsgError("请填写备注")
                } else {
                    var action = $("#infoForm").attr("action");
                    $.post(action, $('#infoForm').serialize(), function (res) {
                        if (res.success) {
                            util.layerMsgSuccess("提交成功", function () {
                                submitFunction('#myForm');
                            });
                        } else {
                            util.layerMsgError("提交失败")
                        }
                    });
                    layer.close(setPayIndex);
                }
            }
        });
    }

    $(function () {
        //加载分页
        loadPageNew({elem: 'page_content', totalCount: '${page.totalCount}', limit: '${page.limit}', page: '${page.page}'});

        $('#myTable').delegate('.option', 'click', function (e) {
            var info = $(this).closest('.info');
            if (!info.hasClass('active')) {//打开
                if (${not empty gatherProject.id}) {
                    var id = $(info).closest("tr").data("id");
                    var content = $(info).next(".info-detail").find("tr:last-child");
                    var length = $(info).next(".info-detail").find(".other-info").length;
                    if (length == 0) {
                        $.ajax({
                            type: 'get',
                            async: false, // 使用同步的方法
                            data: {
                                targetId: id,
                                projectId: '${gatherProject.id}',
                                isNew: util.isValid(formItems) ? false : true
                            },
                            dataType: 'json',
                            success: function (res) {
                                if (res.success) {
                                    if (!util.isValid(formItems)) {
                                        formItems = res.data.fields;
                                    } else {
                                        res.data.fields = formItems;
                                    }
                                    var getTpl = $("#form_template").html();
                                    laytpl(getTpl).render(res.data, function (html) {
                                        content.after(html);
                                    });
                                }
                            },
                            url: '${ctx}/gatherForm/form/getFormInfoByTargetId.do'
                        });
                    }
                }
                $('.info').removeClass('active');
                $(".info-detail").removeClass('dis-block');
                info.toggleClass('active');
                $(info).next(".info-detail").addClass('dis-block');
            } else {
                info.toggleClass('active');
                $(info).next(".info-detail").removeClass('dis-block');
            }
        });

        $("#btnExport").click(function () {
            layer.confirm('确认要导出Excel吗?', {
                icon: 3,
                title: '系统提示'
            }, function (index) {
                var url = "${ctx}/activity/memberAct/export.do?actId=${activity.id}";
                var loadIndex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                $.post(url, $("#myForm").serialize(), function (res) {
                    top.layer.close(loadIndex);
                    if (res.success) {
                        window.location.href = res.data;
                    } else {
                        util.layerMsgError(res.description)
                    }
                });
                top.layer.close(index);
            });
        });

        layui.use(['form', 'laydate'], function () {
            var form = layui.form, laydate = layui.laydate;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })
</script>
</body>
</html>